package com.example.mobile2021606185zhn0511homework;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

public class CarAdapt extends RecyclerView.Adapter<CarAdapt.ViewHolder> {

    private List<car> list01;
    public CarAdapt(List<car> list01){
        this.list01 = list01;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_rv_main_parkinglot,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        car parking_lot = list01.get(position);
        holder.imageView01.setImageResource(parking_lot.getTupian());
        holder.chexing01.setText(parking_lot.getChexing01());
        holder.chexing02.setText(parking_lot.getChexing02());
    }

    @Override
    public int getItemCount() {
        return list01.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        ImageView imageView01;
        TextView chexing01,chexing02;
        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView01 = itemView.findViewById(R.id.imageView01);
            chexing01 = itemView.findViewById(R.id.chexing01);
            chexing02 = itemView.findViewById(R.id.chexing02);
        }
    }

}